<?php

namespace app\index\model;

use think\Db;
use think\Model;

class Search extends Model
{
    // 查询最新注册
    public function latestReg()
    {
        $res = Db::name('user')
            ->field('pass', true)
            ->order('register_time', 'desc')
            ->select();

        return $res;
    }

    // 查询最新登录
    public function recentlyLogged()
    {
        $res = Db::name('user')
            ->field('pass', true)
            ->order('last_login_time', 'desc')
            ->select();

        return $res;
    }

    public function condition($salary,$birthday='')
    {
        if($birthday == null){
            $res = Db::name('user')
                ->where('salary', $salary)
                ->field('pass', true)
                ->select();
        } else {
            $res = Db::name('user')
                ->where('salary', $salary)
                ->where('birthday', '>', $birthday.'-01-01')
                ->where('birthday', '<', $birthday.'-12-31')
                ->field('pass', true)
                ->select();
        }

        return $res;
    }
}
